import click
import tag_source.vscode
import tag_source.stackoverflow
import tag_source.segmentfault
import tag_source.infoq
import tag_source.cnblogs
import tag_source.oschina

@click.command()
@click.option('--source')
def fetch(source):
    click.echo('will fetch tags from %s!' % source)

    sources = {
        'vscode': lambda: tag_source.vscode.fetch(),
        'so': lambda: tag_source.stackoverflow.fetch(),
        'sf': lambda: tag_source.segmentfault.fetch(),
        'infoq': lambda: tag_source.infoq.fetch(),
        'cnblogs': lambda: tag_source.cnblogs.fetch(),
        'oschina': lambda: tag_source.oschina.fetch(),
    }

    action = sources.get(source)
    if action is not None:
        action()
    else:
        print('source {} is not support now.'.format(source))

if __name__ == '__main__':
    fetch()